<script>
	
	export default {
		globalData: {
			base_ImgUrl: "https://posting.imguangguang.com/mocup-miniprogram-",
			jmLogin: false, // 极光登录
			levelList: [],
		},
		onLaunch: function() {
			// 如果保存则认为是登录状态，未保存则为未登录状态。
			
			let userInfo = uni.getStorageSync("userInfo")
			if(userInfo.id) {
				//获取成功即说明本地有保存用户数据，把res.data继续给state.userInfo。并修改登录状态，由此达到登录状态
				this.$store.state.hasLogin = true
				this.$store.state.userInfo = userInfo
			}else {
				// 未登录
				this.$store.state.hasLogin = false
			}
			
			this.initData()
			
			this.$isResolve()
		},
		methods: {
			// 初始化数据
			async initData() {
				// 获取搭配师列表
				this.$u.api.getStylistLevels().then(res => {
					if (res.code === 200) {
						this.globalData.levelList = res.data
						for (let i in this.globalData.levelList) {
							this.globalData.levelList[i].selected = false
						}
					}
				})
			},
		},
		onShow: function() {
			// console.log('App Show')
		},
		onHide: function() {
			// console.log('App Hide')
		}
	}
</script>

<style lang="scss">
	/*每个页面公共css */
	@import "/static/iconfont/font.scss";
	@import "/static/css/main.scss";
	@import "/static/css/animate.css";
	@import "uview-ui/index.scss";

	page {
		background-color: #F7F8FA;
	}
</style>
